/*
Spotter Exercise Manager
Copyright 2011 Evan Nelson.

This file is part of Spotter Exercise Manager.

Spotter Exercise Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Spotter Exercise Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Spotter Exercise Manager.  If not, see <http://www.gnu.org/licenses/>.

The author can be contacted by emailing ean5533@gmail.com
*/

#ifndef WEIGHTLOG_H
#define WEIGHTLOG_H

#include <QtGui/QDialog>
#include <QSqlDatabase>
#include <QDate>
#include <QList>
#include <QTableWidgetItem>

namespace Ui
{
    class WeightLogClass;
}

class WeightLog : public QDialog
{
    Q_OBJECT

public:
    WeightLog(int logID, int mode, QWidget *parent = 0);
    ~WeightLog();
    static const int MODE_VIEW = 1;
    static const int MODE_EDIT = 2;
    static const int MODE_ADD = 3;
    static const int MODE_EDIT_TEMPLATE = 4;
    static const int MODE_ADD_TEMPLATE = 5;

private:
    Ui::WeightLogClass *ui;
    QStringList exercises;      //a constant list of exercises pulled from database
    QStringList weightTypes;    //a constant list of weight types pulled from database
    QSqlDatabase db;
    int logID;
    int mode;                   //the mode in which this form is being called (1=view, 2=edit)
    QString logDate;
    QString templateName;
    void refreshTable();
    void addRow(QString sEx, QString sWt, double weight, int reps, QString sNotes);
    void deleteRow();
    void copyRow(int row);
    void saveData();
    void rebuildExerciseList();
    void moveRow(QTableWidget* table, bool up);
    QList<QTableWidgetItem*> takeRow(QTableWidget *table, int row);
    void setRow(QTableWidget* table, int row, const QList<QTableWidgetItem*>& rowItems);

    QString sDebug;

private slots:
    void on_btnCopy_clicked();
    void on_dateLog_editingFinished();
    void on_btnDelete_clicked();
    void on_btnAdd_clicked();
    void accept();
    void reject();
    void on_actionAdd_new_exercise_triggered();
    void on_actionAdd_New_Row_triggered();
    void on_actionCopy_Row_triggered();
    void on_actionDelete_Row_triggered();
    void on_btnLoadTemplate_clicked();
    void on_btnMoveDown_clicked();
    void on_btnMoveUp_clicked();
};

#endif // WEIGHTLOG_H
